Non-leftmost Unfolding in Partial Evaluation of Logic Programs with Impure Predicates
نویسندگان
چکیده
Partial evaluation of logic programs which contain impure predicates poses non-trivial challenges. Impure predicates include those which produce side-effects, raise errors (or exceptions), and those whose truth value varies according to the degree of instantiation of arguments. In particular, non-leftmost unfolding steps can produce incorrect results since the independence of the computation rule no longer holds in the presence of impure predicates. Existing proposals allow non-leftmost unfolding steps, but at the cost of accuracy: bindings and failure are not propagated backwards to predicates which are potentially impure. In this work we propose a partial evaluation scheme which substantially reduces the situations in which such backpropagation has to be avoided. With this aim, our partial evaluator takes into account the information about purity of predicates expressed in terms of assertions. This allows achieving some optimizations which are not feasible using existing partial evaluation techniques. We argue that our proposal goes beyond existing ones in that it is a) accurate, since the classification of pure vs impure is done at the level of atoms instead of predicates, b) extensible, as the information about purity can be added to programs using assertions without having to modify the partial evaluator itself, and c) automatic, since (backwards) analysis can be used to automatically infer the required assertions. Our approach has been implemented in the context of CiaoPP, the abstract interpretation-based preprocessor of the Ciao logic
منابع مشابه
An Automatic Partial Evaluator for Full Prolog
A partial evaluator for Prolog takes a program and a query and returns a program specialized for all instances of that query. The intention is that the generated program will execute more efficiently than the original one for those instances. This thesis presents “Mixtus”, an automatic partial evaluator for full Prolog, i.e. including non-logical features such as cut, assert, var, write etc. Mi...
متن کاملPrograms Without Failures
We try to formalize the intuitive reasoning which we normally use to get convinced that a query has successful LD-derivations in a program. To this purpose we deene the class of programs and queries without failures which have the property of not having nitely failing derivations. Such property is simple to verify, it is preserved through leftmost unfolding and it can be useful both in verifyin...
متن کاملTowards a Safe Partial Evaluation of Lazy Functional Logic Programs
Partial Evaluation is a well-known technique for specializing programs w.r.t. a given restriction of their input data. Although partial evaluation has been widely investigated in the context of functional and functional logic languages like Haskell or Curry, current schemes are either overly restrictive or destroy sharing through the specialization process, which may produce incorrect specializ...
متن کاملEfficient Local Unfolding with Ancestor Stacks for Full Prolog
Abs t r ac t . The integration of powerful partial evaluation methods into practical compilers for logic programs is still far from reality. This is related both to 1) efficiency issues and to 2) the complications of dealing with practical programs. Regarding efnciency, the most successful unfolding rules used nowadays are based on structural orders applied over (covering) ancestors, i.e., a su...
متن کاملEfficient local unfolding with ancestor stacks
1 I n t r o d u c t i o n The main purpose of partial evaluation (see (Jones et al. 1993) for a general text on the área) is to specialize a given program w.r.t. par t of its input data—henee it is also known as program specialization. Essentially, partial evaluators are nonstandard interpreters which evalúate expressions while enough information is available and residualize them otherwise. The...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2005